import LevelBaseControl from "../LevelCommon/LevelBaseControl";
import InteractiveBase from "../LevelCommon/InteractiveBase";
import DialogDataConst from "../../constant/DialogDataConst";
import GamePropConst from "../../constant/GamePropConst";

export default class LevelControl1 extends LevelBaseControl {
    /** 是否出现过了引导面板*/
    private isShowGuide: boolean = false;
    //#region round1
    /** 的栅栏是否打开了*/
    private isRound1FenceOpen: boolean = false;
    /** 房间门是否打开了*/
    private isRound1RoomOpen: boolean = false;
    /** 栅栏铁链*/
    private chain_prop: Laya.Sprite3D;
    /** 栅栏门*/
    private fenceGate: InteractiveBase;
    // #endregion
    /** 存本地 是否输入过名字*/
    static IS_INPUT_NAME: string = "IS_INPUT_NAME";

    protected startByBase() {
        let round1Container = this.levelObjRoot.getChildAt(0).getChildByName("Container") as Laya.Sprite3D;
        this.chain_prop = (round1Container.getChildByName("FenceGate").getChildByName("Iron chain_props")) as Laya.Sprite3D;
        this.fenceGate = round1Container.getChildByName("FenceGate").getChildByName("Fence_03_props").getComponent(InteractiveBase);
    }

    public DoInteractObjLogic(_name: string): boolean {
        switch (_name) {
            /** round1    *********************************************************************************************/
            /** 点击栅栏*/
            case "Fences":
                if (!this.isRound1FenceOpen) {
                    this.ShowDialog(DialogDataConst.open_fence_door);
                }
                break;
            /**  点击栅栏铁链  需要道具钳子 */
            case "Iron chain_props":
                /** 如果当前选择的钳子道具 开门*/
                if (this.CurSelectProp != null && this.CurSelectProp.id == GamePropConst.ID_SPLIERS) {
                    this.UseCurProp();
                    this.chain_prop.destroy();
                    /** 开门*/
                    this.fenceGate.DoInteractive();
                    this.isRound1FenceOpen = true;
                }
                break;
            /** 点击腐蚀液 如果门没开 返回false 提示要先开门*/
            case "Caustic_props":
                if (this.isRound1FenceOpen) {
                    return true;
                }
                else {
                    this.ShowDialog(DialogDataConst.open_fence_door);
                    return false;
                }
                break;
            /** 点击聚焦火堆 如果没开门 就不聚焦*/
            case "Fire_focus":
                if (this.isRound1FenceOpen) {
                    return true;
                }
                else {
                    this.ShowDialog(DialogDataConst.open_fence_door);
                    return false;
                }
                break;
            /** 点车 判断相机角度 在前面才能聚焦*/
            case "car":
                if (this.cameraControl.curRoateY%360 == 0) {
                    return true;
                }
                else {
                    this.ShowDialog(DialogDataConst.change_another_angle);
                    return false;
                }
                break;
            /** 用火加工了道具*/
            case "fire":
                /** 获得腐蚀液道具*/
                this.GetGamePropById(GamePropConst.ID_CORROSIVE_FLUID);
                break;
            /** 开门(先打开铁栅栏  然后用腐蚀液打开门)*/
            case "door_props":
                /** 如果没有打开铁栅栏*/
                if (!this.isRound1FenceOpen) {
                    this.ShowDialog(DialogDataConst.open_fence_door);
                    return false;
                }
                /** 如果门打开了 进入下一关*/
                if (this.isRound1RoomOpen) {
                    this.FinishLevel();
                    return false;
                }
                /** 门没打开*/
                else {
                    /** 没有使用对应的道具 不能开门*/
                    if (this.CurSelectProp == null || this.CurSelectProp.id != GamePropConst.ID_CORROSIVE_FLUID) {
                        this.ShowDialog(DialogDataConst.door_is_locked);
                        return false;
                    }
                    else {
                        this.UseCurProp();
                        this.isRound1RoomOpen = true;
                        return true;
                    }
                }
                break;
            /** round2    *********************************************************************************************/
            default:
                break;
        }
        return true;
    }
}